namespace Behaving.Composites
{
    // Traverses its child nodes in order, left to right. The Sequence fails as soon as any child fails. If a child returns "running",
    // then the Sequence returns "running", and that child will be traversed first on the next tick (skipping prior children)                  
    // If a sequence fails, it starts over next time.
    // If a sequence stops with a node "running", previous nodes will NOT be run the next time.
    public class Sequence : CompositeExtended
    {
        public Sequence(params Behaviour[] children)
            : base(children)
        {
        }

        protected override RunningState AfterSequenceState { get { return RunningState.Success; } }

        protected override bool SequenceDone(RunningState runningState)
        {
            return runningState == RunningState.Failure;
        }
    }
}